<!-- Chatbooks Export Tab -->
<div id="tabChatbooksExport" class="tab-content">
    <div class="endpoint-section" id="chatbooksExport">
        <h2>
            <span class="endpoint-method post">POST</span>
            <span class="endpoint-path">/api/v1/chatbooks/export - Export Chatbook</span>
        </h2>
        <p>Export conversations and character data to a chatbook file.</p>

        <div class="form-group">
            <label for="chatbooksExport_payload">Export Configuration (JSON):</label>
            <textarea id="chatbooksExport_payload" class="code-input" rows="15">{
  "conversation_ids": ["conv_123", "conv_456"],
  "character_ids": ["char_789"],
  "format": "json",
  "include_metadata": true,
  "compress": false,
  "options": {
    "include_system_messages": true,
    "include_timestamps": true,
    "include_character_cards": true
  }
}</textarea>
        </div>

        <button class="api-button" onclick="makeRequest('chatbooksExport', 'POST', '/api/v1/chatbooks/export', 'json')">
            Export Chatbook
        </button>

        <h3>cURL Command:</h3>
        <pre id="chatbooksExport_curl">---</pre>

        <h3>Response:</h3>
        <pre id="chatbooksExport_response">---</pre>
    </div>

    <div class="endpoint-section" id="chatbooksImport">
        <h2>
            <span class="endpoint-method post">POST</span>
            <span class="endpoint-path">/api/v1/chatbooks/import - Import Chatbook</span>
        </h2>
        <p>Import conversations and character data from a chatbook file.</p>

        <div class="form-group">
            <label for="chatbooksImport_file">Chatbook File:</label>
            <input type="file" id="chatbooksImport_file" accept=".json,.jsonl,.cbk">
        </div>

        <div class="form-group">
            <label for="chatbooksImport_options">Import Options (JSON):</label>
            <textarea id="chatbooksImport_options" class="code-input" rows="8">{
  "merge_strategy": "overwrite",
  "validate_before_import": true,
  "import_characters": true,
  "import_conversations": true
}</textarea>
        </div>

        <button class="api-button" onclick="makeRequest('chatbooksImport', 'POST', '/api/v1/chatbooks/import', 'form')">
            Import Chatbook
        </button>

        <h3>cURL Command:</h3>
        <pre id="chatbooksImport_curl">---</pre>

        <h3>Response:</h3>
        <pre id="chatbooksImport_response">---</pre>
    </div>

    <div class="endpoint-section" id="chatbooksPreview">
        <h2>
            <span class="endpoint-method post">POST</span>
            <span class="endpoint-path">/api/v1/chatbooks/preview - Preview Export</span>
        </h2>
        <p>Preview what will be exported without creating the file.</p>

        <div class="form-group">
            <label for="chatbooksPreview_payload">Preview Request (JSON):</label>
            <textarea id="chatbooksPreview_payload" class="code-input" rows="10">{
  "conversation_ids": ["conv_123"],
  "character_ids": ["char_789"],
  "format": "json",
  "summary_only": true
}</textarea>
        </div>

        <button class="api-button" onclick="makeRequest('chatbooksPreview', 'POST', '/api/v1/chatbooks/preview', 'json')">
            Preview Export
        </button>

        <h3>cURL Command:</h3>
        <pre id="chatbooksPreview_curl">---</pre>

        <h3>Response:</h3>
        <pre id="chatbooksPreview_response">---</pre>
    </div>
</div>

<!-- Chatbooks Jobs Tab -->
<div id="tabChatbooksJobs" class="tab-content">
    <div class="endpoint-section" id="chatbooksExportJobs">
        <h2>
            <span class="endpoint-method get">GET</span>
            <span class="endpoint-path">/api/v1/chatbooks/export/jobs - List Export Jobs</span>
        </h2>
        <p>List all export jobs with their status.</p>

        <div class="form-group">
            <label for="chatbooksExportJobs_status">Filter by Status:</label>
            <select id="chatbooksExportJobs_status">
                <option value="">All</option>
                <option value="pending">Pending</option>
                <option value="processing">Processing</option>
                <option value="completed">Completed</option>
                <option value="failed">Failed</option>
            </select>
        </div>

        <button class="api-button" onclick="makeRequest('chatbooksExportJobs', 'GET', '/api/v1/chatbooks/export/jobs', 'query')">
            List Export Jobs
        </button>

        <h3>cURL Command:</h3>
        <pre id="chatbooksExportJobs_curl">---</pre>

        <h3>Response:</h3>
        <pre id="chatbooksExportJobs_response">---</pre>
    </div>

    <div class="endpoint-section" id="chatbooksExportJob">
        <h2>
            <span class="endpoint-method get">GET</span>
            <span class="endpoint-path">/api/v1/chatbooks/export/jobs/{job_id} - Get Export Job</span>
        </h2>
        <p>Get details of a specific export job.</p>

        <div class="form-group">
            <label for="chatbooksExportJob_id">Job ID <span class="required">*</span>:</label>
            <input type="text" id="chatbooksExportJob_id" placeholder="job_123">
        </div>

        <button class="api-button" onclick="makeRequest('chatbooksExportJob', 'GET', '/api/v1/chatbooks/export/jobs/{id}', 'path')">
            Get Job Details
        </button>

        <h3>cURL Command:</h3>
        <pre id="chatbooksExportJob_curl">---</pre>

        <h3>Response:</h3>
        <pre id="chatbooksExportJob_response">---</pre>
    </div>

    <div class="endpoint-section" id="chatbooksDownload">
        <h2>
            <span class="endpoint-method get">GET</span>
            <span class="endpoint-path">/api/v1/chatbooks/download/{job_id} - Download Chatbook</span>
        </h2>
        <p>Download the exported chatbook file.</p>

        <div class="form-group">
            <label for="chatbooksDownload_id">Job ID <span class="required">*</span>:</label>
            <input type="text" id="chatbooksDownload_id" placeholder="job_123">
        </div>

        <button class="api-button" onclick="downloadFile('/api/v1/chatbooks/download/{id}', 'chatbooksDownload_id')">
            Download Chatbook
        </button>

        <h3>cURL Command:</h3>
        <pre id="chatbooksDownload_curl">---</pre>

        <h3>Response:</h3>
        <pre id="chatbooksDownload_response">File will be downloaded to your browser</pre>
    </div>

    <div class="endpoint-section" id="chatbooksImportJobs">
        <h2>
            <span class="endpoint-method get">GET</span>
            <span class="endpoint-path">/api/v1/chatbooks/import/jobs - List Import Jobs</span>
        </h2>
        <p>List all import jobs with their status.</p>

        <div class="form-group">
            <label for="chatbooksImportJobs_status">Filter by Status:</label>
            <select id="chatbooksImportJobs_status">
                <option value="">All</option>
                <option value="pending">Pending</option>
                <option value="processing">Processing</option>
                <option value="completed">Completed</option>
                <option value="failed">Failed</option>
            </select>
        </div>

        <button class="api-button" onclick="makeRequest('chatbooksImportJobs', 'GET', '/api/v1/chatbooks/import/jobs', 'query')">
            List Import Jobs
        </button>

        <h3>cURL Command:</h3>
        <pre id="chatbooksImportJobs_curl">---</pre>

        <h3>Response:</h3>
        <pre id="chatbooksImportJobs_response">---</pre>
    </div>

    <div class="endpoint-section" id="chatbooksCleanup">
        <h2>
            <span class="endpoint-method post">POST</span>
            <span class="endpoint-path">/api/v1/chatbooks/cleanup - Cleanup Expired Exports</span>
        </h2>
        <p>Remove expired export files and job records.</p>

        <div class="form-group">
            <label for="chatbooksCleanup_days">Days to Keep:</label>
            <input type="number" id="chatbooksCleanup_days" value="7" min="1" max="30">
        </div>

        <button class="api-button" onclick="makeRequest('chatbooksCleanup', 'POST', '/api/v1/chatbooks/cleanup', 'json')">
            Run Cleanup
        </button>

        <h3>cURL Command:</h3>
        <pre id="chatbooksCleanup_curl">---</pre>

        <h3>Response:</h3>
        <pre id="chatbooksCleanup_response">---</pre>
    </div>
</div>
